Integrand size = 13, antiderivative size = 61 \[ \int \frac {\sin ^2(x)}{a+b \sin (x)} \, dx=-\frac {a x}{b^2}+\frac {2 a^2 \arctan \left (\frac {b+a \tan \left (\frac {x}{2}\right )}{\sqrt {a^2-b^2}}\right )}{b^2 \sqrt {a^2-b^2}}-\frac {\cos (x)}{b} \]
[Out]
Time = 0.08 (sec) , antiderivative size = 61, normalized size of antiderivative = 1.00, number of steps used = 6, number of rules used = 6, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.462, Rules used = {2825, 12, 2814, 2739, 632, 210} \[ \int \frac {\sin ^2(x)}{a+b \sin (x)} \, dx=\frac {2 a^2 \arctan \left (\frac {a \tan \left (\frac {x}{2}\right )+b}{\sqrt {a^2-b^2}}\right )}{b^2 \sqrt {a^2-b^2}}-\frac {a x}{b^2}-\frac {\cos (x)}{b} \]
[In]
[Out]
Rule 12
Rule 210
Rule 632
Rule 2739
Rule 2814
Rule 2825
Rubi steps \begin{align*} \text {integral}& = -\frac {\cos (x)}{b}-\frac {\int \frac {a \sin (x)}{a+b \sin (x)} \, dx}{b} \\ & = -\frac {\cos (x)}{b}-\frac {a \int \frac {\sin (x)}{a+b \sin (x)} \, dx}{b} \\ & = -\frac {a x}{b^2}-\frac {\cos (x)}{b}+\frac {a^2 \int \frac {1}{a+b \sin (x)} \, dx}{b^2} \\ & = -\frac {a x}{b^2}-\frac {\cos (x)}{b}+\frac {\left (2 a^2\right ) \text {Subst}\left (\int \frac {1}{a+2 b x+a x^2} \, dx,x,\tan \left (\frac {x}{2}\right )\right )}{b^2} \\ & = -\frac {a x}{b^2}-\frac {\cos (x)}{b}-\frac {\left (4 a^2\right ) \text {Subst}\left (\int \frac {1}{-4 \left (a^2-b^2\right )-x^2} \, dx,x,2 b+2 a \tan \left (\frac {x}{2}\right )\right )}{b^2} \\ & = -\frac {a x}{b^2}+\frac {2 a^2 \arctan \left (\frac {b+a \tan \left (\frac {x}{2}\right )}{\sqrt {a^2-b^2}}\right )}{b^2 \sqrt {a^2-b^2}}-\frac {\cos (x)}{b} \\ \end{align*}
Time = 0.14 (sec) , antiderivative size = 56, normalized size of antiderivative = 0.92 \[ \int \frac {\sin ^2(x)}{a+b \sin (x)} \, dx=-\frac {a x-\frac {2 a^2 \arctan \left (\frac {b+a \tan \left (\frac {x}{2}\right )}{\sqrt {a^2-b^2}}\right )}{\sqrt {a^2-b^2}}+b \cos (x)}{b^2} \]
[In]
[Out]
Time = 0.45 (sec) , antiderivative size = 71, normalized size of antiderivative = 1.16
method | result | size |
default | \(-\frac {2 \left (\frac {b}{1+\tan ^{2}\left (\frac {x}{2}\right )}+a \arctan \left (\tan \left (\frac {x}{2}\right )\right )\right )}{b^{2}}+\frac {2 a^{2} \arctan \left (\frac {2 a \tan \left (\frac {x}{2}\right )+2 b}{2 \sqrt {a^{2}-b^{2}}}\right )}{b^{2} \sqrt {a^{2}-b^{2}}}\) | \(71\) |
risch | \(-\frac {a x}{b^{2}}-\frac {{\mathrm e}^{i x}}{2 b}-\frac {{\mathrm e}^{-i x}}{2 b}+\frac {a^{2} \ln \left ({\mathrm e}^{i x}+\frac {i a \sqrt {-a^{2}+b^{2}}+a^{2}-b^{2}}{b \sqrt {-a^{2}+b^{2}}}\right )}{\sqrt {-a^{2}+b^{2}}\, b^{2}}-\frac {a^{2} \ln \left ({\mathrm e}^{i x}+\frac {i a \sqrt {-a^{2}+b^{2}}-a^{2}+b^{2}}{b \sqrt {-a^{2}+b^{2}}}\right )}{\sqrt {-a^{2}+b^{2}}\, b^{2}}\) | \(158\) |
[In]
[Out]
none
Time = 0.34 (sec) , antiderivative size = 231, normalized size of antiderivative = 3.79 \[ \int \frac {\sin ^2(x)}{a+b \sin (x)} \, dx=\left [-\frac {\sqrt {-a^{2} + b^{2}} a^{2} \log \left (\frac {{\left (2 \, a^{2} - b^{2}\right )} \cos \left (x\right )^{2} - 2 \, a b \sin \left (x\right ) - a^{2} - b^{2} + 2 \, {\left (a \cos \left (x\right ) \sin \left (x\right ) + b \cos \left (x\right )\right )} \sqrt {-a^{2} + b^{2}}}{b^{2} \cos \left (x\right )^{2} - 2 \, a b \sin \left (x\right ) - a^{2} - b^{2}}\right ) + 2 \, {\left (a^{3} - a b^{2}\right )} x + 2 \, {\left (a^{2} b - b^{3}\right )} \cos \left (x\right )}{2 \, {\left (a^{2} b^{2} - b^{4}\right )}}, -\frac {\sqrt {a^{2} - b^{2}} a^{2} \arctan \left (-\frac {a \sin \left (x\right ) + b}{\sqrt {a^{2} - b^{2}} \cos \left (x\right )}\right ) + {\left (a^{3} - a b^{2}\right )} x + {\left (a^{2} b - b^{3}\right )} \cos \left (x\right )}{a^{2} b^{2} - b^{4}}\right ] \]
[In]
[Out]
Leaf count of result is larger than twice the leaf count of optimal. 1192 vs. \(2 (49) = 98\).
Time = 101.69 (sec) , antiderivative size = 1192, normalized size of antiderivative = 19.54 \[ \int \frac {\sin ^2(x)}{a+b \sin (x)} \, dx=\text {Too large to display} \]
[In]
[Out]
Exception generated. \[ \int \frac {\sin ^2(x)}{a+b \sin (x)} \, dx=\text {Exception raised: ValueError} \]
[In]
[Out]
none
Time = 0.32 (sec) , antiderivative size = 77, normalized size of antiderivative = 1.26 \[ \int \frac {\sin ^2(x)}{a+b \sin (x)} \, dx=\frac {2 \, {\left (\pi \left \lfloor \frac {x}{2 \, \pi } + \frac {1}{2} \right \rfloor \mathrm {sgn}\left (a\right ) + \arctan \left (\frac {a \tan \left (\frac {1}{2} \, x\right ) + b}{\sqrt {a^{2} - b^{2}}}\right )\right )} a^{2}}{\sqrt {a^{2} - b^{2}} b^{2}} - \frac {a x}{b^{2}} - \frac {2}{{\left (\tan \left (\frac {1}{2} \, x\right )^{2} + 1\right )} b} \]
[In]
[Out]
Time = 7.07 (sec) , antiderivative size = 623, normalized size of antiderivative = 10.21 \[ \int \frac {\sin ^2(x)}{a+b \sin (x)} \, dx=-\frac {2}{b\,\left ({\mathrm {tan}\left (\frac {x}{2}\right )}^2+1\right )}-\frac {a\,x}{b^2}-\frac {a^2\,\mathrm {atan}\left (\frac {\frac {a^2\,\left (\frac {32\,a^4}{b}-\frac {32\,\mathrm {tan}\left (\frac {x}{2}\right )\,\left (2\,a^5\,b-2\,a^3\,b^3\right )}{b^3}+\frac {a^2\,\left (32\,a^2\,b^2+64\,a^3\,b\,\mathrm {tan}\left (\frac {x}{2}\right )+\frac {a^2\,\left (32\,a^2\,b^3+\frac {32\,\mathrm {tan}\left (\frac {x}{2}\right )\,\left (3\,a\,b^7-2\,a^3\,b^5\right )}{b^3}\right )}{b^2\,\sqrt {b^2-a^2}}\right )}{b^2\,\sqrt {b^2-a^2}}\right )\,1{}\mathrm {i}}{b^2\,\sqrt {b^2-a^2}}-\frac {a^2\,\left (\frac {32\,\mathrm {tan}\left (\frac {x}{2}\right )\,\left (2\,a^5\,b-2\,a^3\,b^3\right )}{b^3}-\frac {32\,a^4}{b}+\frac {a^2\,\left (32\,a^2\,b^2+64\,a^3\,b\,\mathrm {tan}\left (\frac {x}{2}\right )-\frac {a^2\,\left (32\,a^2\,b^3+\frac {32\,\mathrm {tan}\left (\frac {x}{2}\right )\,\left (3\,a\,b^7-2\,a^3\,b^5\right )}{b^3}\right )}{b^2\,\sqrt {b^2-a^2}}\right )}{b^2\,\sqrt {b^2-a^2}}\right )\,1{}\mathrm {i}}{b^2\,\sqrt {b^2-a^2}}}{\frac {128\,a^5\,\mathrm {tan}\left (\frac {x}{2}\right )}{b^3}+\frac {a^2\,\left (\frac {32\,a^4}{b}-\frac {32\,\mathrm {tan}\left (\frac {x}{2}\right )\,\left (2\,a^5\,b-2\,a^3\,b^3\right )}{b^3}+\frac {a^2\,\left (32\,a^2\,b^2+64\,a^3\,b\,\mathrm {tan}\left (\frac {x}{2}\right )+\frac {a^2\,\left (32\,a^2\,b^3+\frac {32\,\mathrm {tan}\left (\frac {x}{2}\right )\,\left (3\,a\,b^7-2\,a^3\,b^5\right )}{b^3}\right )}{b^2\,\sqrt {b^2-a^2}}\right )}{b^2\,\sqrt {b^2-a^2}}\right )}{b^2\,\sqrt {b^2-a^2}}+\frac {a^2\,\left (\frac {32\,\mathrm {tan}\left (\frac {x}{2}\right )\,\left (2\,a^5\,b-2\,a^3\,b^3\right )}{b^3}-\frac {32\,a^4}{b}+\frac {a^2\,\left (32\,a^2\,b^2+64\,a^3\,b\,\mathrm {tan}\left (\frac {x}{2}\right )-\frac {a^2\,\left (32\,a^2\,b^3+\frac {32\,\mathrm {tan}\left (\frac {x}{2}\right )\,\left (3\,a\,b^7-2\,a^3\,b^5\right )}{b^3}\right )}{b^2\,\sqrt {b^2-a^2}}\right )}{b^2\,\sqrt {b^2-a^2}}\right )}{b^2\,\sqrt {b^2-a^2}}}\right )\,2{}\mathrm {i}}{b^2\,\sqrt {b^2-a^2}} \]
[In]
[Out]